package com.emperor.product.app;

import java.util.Map;

import org.apache.log4j.Logger;

import com.emperor.core.app.App;
import com.emperor.core.app.AppConstant;
import com.emperor.core.app.AppCtrl;

public class ProductAppCtrl implements AppCtrl {

	public static final String PRODUCT_CTRL = "product.ctrl";
	public static final String PRODUCT_NEW = "product.new";
	public static final String PRODUCT_MGM = "product.mgm";
	public static final String PRODUCT_MOV = "product.mov";
	
	public static final String PRODUCT_MSG = "product.msg";
	public static final String PRODUCT_ID = "product.id";
	public static final String PRODUCT_LIST = "product.list";
	public static final String PRODUCT_ACTIONNAME = "product.actionname";
	
	public static Logger log = Logger.getLogger(ProductAppCtrl.class);
	
	@Override
	public void doProcess(Map<String, Object> params) {
			App app = null;
			if (params == null) {
				log.error("Param is null");
			} else if (params.get(AppConstant.ACTION).equals(PRODUCT_MGM)) {
				app = new ProductAppMgm(params);
			} else if (params.get(AppConstant.ACTION).equals(PRODUCT_MOV)) {
				app = new ProductAppMov(params);
			} else {
				app = new ProductAppNew(params);
			}
			
			if (app != null) {
				app.open();
			}
	}

}
